package acm.pta3;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(in.readLine());
        for (int i = 0; i < N; i++) {
            int num = Integer.parseInt(in.readLine());
            System.out.println(isPrime2(num) ? "Yes" : "No");
        }
    }
    public static boolean isPrime2(int num) {
        if (num <= 1) {
            return false;
        }
        if (num>=5 && num % 6 != 1 && num % 6 != 5)
        {
            return false;
        }

        for (int i = 2; i * i <= num; i++) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }
}
